package com.cart.controller;

import com.cart.service.CartService;
import com.cart.util.CommonResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/cart")
public class CartController {
    @Autowired
    CartService cartService;

    @GetMapping("/list")
    public CommonResponse showCart(@RequestParam(value = "token")String token){
        return cartService.showCart(token);
    }

    @PostMapping("/addtocart")
    public CommonResponse addToCart(@RequestParam(value = "token")String token,@RequestParam(value = "fnum")int fnum,
                                  @RequestParam(value = "fname")String fname){
        return cartService.addToCart(token,fnum,fname);
    }
}
